package tools.clustering_old;

import tools.utils.DoubleMatrix;

public class MatrixManipulation {

	public static DoubleMatrix euclidianDistance(DoubleMatrix in)throws Exception{
		DoubleMatrix out =new DoubleMatrix(in.getHeight(),in.getHeight());
		double distance=0,a=0;
		for(int i=0;i<in.getHeight();i++){
			out.set(i,i,0);
			for(int j=0;j<i;j++){
				distance=0;
				for (int k = 0; k < in.getWidth(); k++) {
					a=in.get(i,k)-in.get(j,k);
					distance+=a*a;
				}
				distance=Math.sqrt(distance);
				out.set(i,j,distance);
				out.set(j,i,distance);
			}
		}
		return out;
	}
}
